package cn.com.chengmandian.bike.controller;


import cn.com.chengmandian.bike.dto.SettingAdDto;
import cn.com.chengmandian.bike.model.EbSettingAd;
import cn.com.chengmandian.bike.service.IEbSettingAdService;
import cn.com.chengmandian.core.web.pojo.AgentInfo;
import cn.com.chengmandian.core.web.pojo.AjaxResult;
import cn.com.chengmandian.core.web.utils.LocalMapUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 电单车运营-广告配置 前端控制器
 * </p>
 *
 * @author AutoGenerator
 * @since 2022-02-09
 */
@Api(tags = "广告配置")
@RestController
@RequestMapping("/setting/ad")
public class EbSettingAdController {

    @Autowired
    private IEbSettingAdService settingAdService;


    @ApiOperation("广告配置列表信息(无需登录)")
    @GetMapping(value = "/list",name = "广告配置列表信息")
    public AjaxResult<List<EbSettingAd>> list(SettingAdDto dto){
        AgentInfo agentInfo = LocalMapUtil.getAgentInfo();
        Assert.notNull(agentInfo.getAreaId(), "缺少运营区");
        return AjaxResult.success(settingAdService.getList(agentInfo.getId(), agentInfo.getAreaId(), dto.getPosition()));
    }
}
